#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <unordered_map>
#include <vector>
#include <queue>

using namespace std;

struct cmp {
    bool operator()(pair<int, int> p1, pair<int, int> p2)
    {
        return p1.second > p2.second;
    }
};

vector<int> topKFrequent(vector<int>& nums, int k) {
    unordered_map<int, int> hash;
    priority_queue<pair<int, int>, vector<pair<int, int>>, cmp> heap;

    for (auto e : nums)
        hash[e]++;

    for (auto p : hash)
    {
        heap.push(p);
        if (heap.size() > k)
            heap.pop();
    }

    vector<int> ret;
    while (!heap.empty())
    {
        ret.push_back(heap.top().first);
        heap.pop();
    }

    return ret;
}

int main()
{

	return 0;
}